package com.controller.user;

import com.model.pojo.annotation.CheckToken;
import com.model.pojo.RepCode;
import com.model.pojo.RepEntity;
import com.model.vo.configVo.RecordInfo;
import com.server.chart.ChartsUtilService;
import com.server.user.RecodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RecodeController {
    @Autowired
    RecodeService recodeService;
    @Autowired
    ChartsUtilService chartsUtilService;

    @CheckToken
    @RequestMapping("/getChartRecord")
    public RepEntity getChartRecord(@RequestHeader String token){
        return recodeService.getChartRecord(token);
    }

    @CheckToken
    @RequestMapping("/getDashRecord")
    public RepEntity getDashRecord(@RequestHeader String token){
        return recodeService.getDashRecord(token);
    }

    @CheckToken
    @RequestMapping("/addRecord")
    public RepEntity inputRecord(@RequestHeader String token,@RequestBody RecordInfo body){
        chartsUtilService.inputRecord(token, body);
        return new RepEntity(RepCode.success);
    }
}
